<template>
    <div>
        <div id="comment_container">
            <textarea v-model="comment" placeholder="这件商品怎么样呢？"
            class="c-txt"></textarea>
        </div>
        <div class="big-btn" :class="{disabled: !comment}" @click="publish">评价</div>
    </div>
</template>
<script>
import { Indicator, Toast } from 'mint-ui'
export default {
    name: 'writeComment',
    data(){
        return{
            comment: ''
        }
    },
    methods: {
        async publish(){
            if(!this.comment) return
            Indicator.open()
            const {success, msg} = await this.$store.dispatch('order/writeComment', {
                orderId: this.$route.params.orderId,
                goodsId: this.$route.params.goodsId,
                content: this.comment
            })
            Indicator.close()
            if(success) this.$router.replace('/order/list/1')
            else Toast(msg)
        }
    }
}
</script>
<style lang="less" scoped>
#comment_container{
    padding: .3rem;
    background: #fff;
    textarea{
        width: 100%;
        height: 2rem;;
    }
}
.big-btn{
    display: block;
    margin: 1.5rem auto;
}
</style>
